package com.kitchen.ui.dialog.decorate
{
	import com.kitchen.AbstractButton;

	import flash.display.BitmapData;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	internal class DynamicButton extends AbstractButton
	{
		private var checked:Boolean = false;
		
		public function DynamicButton(bitdata:BitmapData)
		{
			super(bitdata);
		}
		
		override protected function getBitmapData(bitdata:BitmapData):BitmapData{
			this.h = 31;
			this.w = 64;
			var cbitdata:BitmapData = new BitmapData(this.w*4, this.h);
			cbitdata.copyPixels(bitdata, new Rectangle(290, 782, this.w*4, this.h), new Point());
			return cbitdata;
		}
		
		override protected function onMouseOver(me:MouseEvent):void{
			this.offsetX(this.w);
		}
		
		override protected function onMouseDown(me:MouseEvent):void{
			this.offsetX(this.w*2);
		}
		
		override protected function onMouseOut(me:MouseEvent):void{
			if(this.checked){
				this.offsetX(this.w*3);
			}else{
				this.offsetX(0);
			}
		}
		
		public function setChecked(ck:Boolean):void{
			this.checked = ck;
			this.onMouseOut(new MouseEvent(''));
		}
		
	}
}